#include <stdio.h>
#include <vector>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <limits.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <ifaddrs.h>
#include <net/if.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <thread>
#include <string.h>
#include <cerrno>
#include <list>
#include <map>
#include <signal.h>
#include <mutex>
#include <sys/types.h>
#include <sys/wait.h>

#include "http.h"
#include "json.h"


int main(int argc, char *argv[]) {
    const char *http_op = getenv("HTTP_OP");
    int socket_fd = atoi(getenv("socket_fd"));
    ssize_t size = atoi(getenv("Content_Length"));
    bool keep_alive = atoi(getenv("keep_alive"));
    const char *token = getenv("PRIVATE_TOKEN");
    const char *home = getenv("HOME");
    json_t json;
    char buf[1024];

    json.sock_recv(socket_fd, size);
    print_json(json);
    
    send_200(socket_fd, strlen(http_op), "text/html", false);
    send(socket_fd, http_op, strlen(http_op), 0);
    return 0;
}